#include <iostream>

using namespace std;

class Activity{

public:
	void onCreate()
	{
		onInitView();
		onInitData();
	}

	// 定义虚函数，虚函数必须在子类实现，否则子类是抽象类，不能进行实例化
	// 虚函数类似Java中的抽象类
	virtual void onInitView() = 0;
	virtual void onInitData() = 0;
public:
	Activity()
	{
		cout << "父类构造函数" << endl;
	}
	~Activity()
	{
		cout << "父类析构函数" << endl;
	}
};

class MainActivity: public Activity{
public:
	virtual void onInitView()
	{
		cout << "onInitView" << endl;
	}
	virtual void onInitData()
	{
		cout << "onInitData" << endl;
	}
public:
	MainActivity()
	{
		cout << "子类构造函数" << endl;
	}
	~MainActivity()
	{
		cout << "子类析构函数" << endl;
	}
};

int main()
{
	MainActivity *activity = new MainActivity();	

	activity->onCreate();

	delete(activity);

	return 0;
}
